Security News
PyPI Introduces Digital Attestations to Strengthen Python Package Security
PyPI now supports digital attestations, enhancing security and trust by allowing package maintainers to verify the authenticity of Python packages.
@fluentui/theme
Advanced tools
@fluentui/theme is a package that provides theming capabilities for Fluent UI components. It allows developers to define and apply custom themes, including colors, fonts, and other design tokens, to ensure a consistent look and feel across their applications.
Custom Theme Creation
This feature allows you to create a custom theme by defining a palette of colors. The `createTheme` function takes an object with color definitions and returns a theme object that can be applied to Fluent UI components.
const { createTheme } = require('@fluentui/theme');
const myTheme = createTheme({
palette: {
themePrimary: '#0078d4',
themeLighterAlt: '#eff6fc',
themeLighter: '#deecf9',
themeLight: '#c7e0f4',
themeTertiary: '#71afe5',
themeSecondary: '#2b88d8',
themeDarkAlt: '#106ebe',
themeDark: '#005a9e',
themeDarker: '#004578',
neutralLighterAlt: '#faf9f8',
neutralLighter: '#f3f2f1',
neutralLight: '#edebe9',
neutralQuaternaryAlt: '#e1dfdd',
neutralQuaternary: '#d0d0d0',
neutralTertiaryAlt: '#c8c6c4',
neutralTertiary: '#a19f9d',
neutralSecondary: '#605e5c',
neutralPrimaryAlt: '#3b3a39',
neutralPrimary: '#323130',
neutralDark: '#201f1e',
black: '#000000',
white: '#ffffff'
}
});
Applying Themes
This feature allows you to apply a custom theme to your application. The `loadTheme` function takes a theme object and applies it globally, ensuring that all Fluent UI components use the defined theme.
const { loadTheme } = require('@fluentui/theme');
const myTheme = createTheme({
palette: {
themePrimary: '#0078d4',
themeLighterAlt: '#eff6fc',
themeLighter: '#deecf9',
themeLight: '#c7e0f4',
themeTertiary: '#71afe5',
themeSecondary: '#2b88d8',
themeDarkAlt: '#106ebe',
themeDark: '#005a9e',
themeDarker: '#004578',
neutralLighterAlt: '#faf9f8',
neutralLighter: '#f3f2f1',
neutralLight: '#edebe9',
neutralQuaternaryAlt: '#e1dfdd',
neutralQuaternary: '#d0d0d0',
neutralTertiaryAlt: '#c8c6c4',
neutralTertiary: '#a19f9d',
neutralSecondary: '#605e5c',
neutralPrimaryAlt: '#3b3a39',
neutralPrimary: '#323130',
neutralDark: '#201f1e',
black: '#000000',
white: '#ffffff'
}
});
loadTheme(myTheme);
Font Customization
This feature allows you to customize the fonts used in your application. The `createTheme` function can take a `fonts` object where you can define different font styles for various text sizes.
const { createTheme } = require('@fluentui/theme');
const myTheme = createTheme({
fonts: {
small: {
fontSize: '10px',
fontWeight: 'normal'
},
medium: {
fontSize: '14px',
fontWeight: 'semibold'
},
large: {
fontSize: '18px',
fontWeight: 'bold'
}
}
});
styled-components is a library for React and React Native that allows you to use component-level styles in your application. It uses tagged template literals to style your components. Unlike @fluentui/theme, which is specifically for Fluent UI components, styled-components can be used with any React component.
Emotion is a library designed for writing CSS styles with JavaScript. It provides powerful and flexible styling capabilities with a focus on performance. Similar to styled-components, Emotion can be used with any React component, whereas @fluentui/theme is tailored for Fluent UI components.
theme-ui is a library for creating themeable user interfaces based on constraint-based design principles. It provides a set of tools for defining and applying themes in React applications. While @fluentui/theme is specific to Fluent UI, theme-ui offers a more general approach to theming.
Basic building blocks for Fluent UI React Themes
Define your own theme based on an existing theme:
import { createTheme, Theme, FontWeights } from '@fluentui/theme';
export const MyTheme: Theme = createTheme({
components: {
Button: {
variants: {
fontWeight: FontWeights.semibold,
paddingLeft: '24px',
paddingRight: '24px',
},
},
},
});
FAQs
Basic building blocks for Fluent UI React Component themes
The npm package @fluentui/theme receives a total of 71,994 weekly downloads. As such, @fluentui/theme popularity was classified as popular.
We found that @fluentui/theme demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 12 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
PyPI now supports digital attestations, enhancing security and trust by allowing package maintainers to verify the authenticity of Python packages.
Security News
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.